/*
-------------------------------------------------

	UI.h

	Dmitriy Kuzmenko (Dgut)

-------------------------------------------------
*/

#ifndef __AUTUMN_UI_H__
#define __AUTUMN_UI_H__

#include "Singleton.h"
#include <list>

namespace Autumn
{

#define gUI UI::GetInstance()

class Screen;

class UI : public Singleton< UI >
{
	Screen *						screen;
	Screen *						newScreen;

									UI( void );
									~UI( void );
public:
	const bool						Init( void );
	void							Shutdown( void );
	void							Frame( void );
	
	Screen * const					GetScreen( void ) const;
	void							SetScreen( Screen * screen );
	
	friend class					Singleton< UI >;
};

class Control;

class Screen
{
	std::list< Control * >			controls;
public:
									Screen( void );
	virtual							~Screen( void );

	virtual void					Frame( void );
	virtual void					Draw( void ) const;

	void							AddControl( Control * control );

	virtual void					Focus( void );
	virtual void					Blur( void );

	virtual const bool				IsBlur( void );
};

class Control
{
public:
	enum HorizontalAlign
	{
		LEFT,
		CENTER,
		RIGHT,
	};

	enum VerticalAlign
	{
		BOTTOM,
		MIDDLE,
		TOP,
	};
private:
	HorizontalAlign					ha;
	VerticalAlign					va;

	float							x;
	float							y;
	float							width;
	float							height;

	bool							visible;

	bool							down;
	bool							move;
	bool							up;
public:
									Control( HorizontalAlign ha, VerticalAlign va, float x, float y, float width, float height );
	virtual							~Control( void );

	virtual void					Frame( void );
	virtual void					Draw( void ) const;

	void							SetVisible( bool visible );

	const bool						IsVisible( void ) const;

	const bool						IsDown( void ) const;
	const bool						IsMove( void ) const;
	const bool						IsUp( void ) const;

	const float						GetGlobalX( void ) const;
	const float						GetGlobalY( void ) const;

	const float						Width( void ) const;
	const float						Height( void ) const;
};

class Label : public Control
{
	static const int				MAX_TEXT = 256;
	char							text[ MAX_TEXT ];
public:
									Label( HorizontalAlign ha, VerticalAlign va, float x, float y, float width, float height, const char * text );
	virtual							~Label( void );

	void							SetText( const char * text, ... );

	const char * const				Text( void ) const;
};

class Button : public Control
{
	void							( * action )( void );
public:
									Button( HorizontalAlign ha, VerticalAlign va, float x, float y, float width, float height, void ( * action )( void ) );
	virtual							~Button( void );

	virtual void					Frame( void );
};

/*class TextButton : public Label, public Button
{
public:
									TextButton( HorizontalAlign ha, VerticalAlign va, float x, float y, float width, float height, const char * text, void ( * action )( void ) );
	virtual							~TextButton( void );
};*/

}	// namespace Autumn

#endif	// !!! __AUTUMN_UI_H__ !!!